<template>
  <!-- Vue3组件中的模板结构可以没有跟标签 -->
  <h1>APP组件</h1>
  <h2>Vue3 ref函数</h2>
  <hr>
  <h3>姓名：{{ procyPerson.name }}</h3>
  <h3>年龄：{{ procyPerson.age }}</h3>
  <h3>兴趣爱好：{{ procyPerson.hobby }}</h3>
  <h4>工作类型：{{ procyPerson.job.type }} </h4>
  <h4>工作类型：{{ procyPerson.job.salary }}k </h4>

  <button @click="updatePerson">修改人信息</button>
  <hr>
</template>

<script>
import { reactive } from 'vue';

export default {
  name: 'App',
  // 此处只是测试一下setup，暂时不考虑响应式问题
  setup() {

    const person = {
      name: "张三",
      age: 18,
      job: {
        type: "前端工程师",
        salary: 10
      },
      hobby: ["抽烟", "喝酒", "打牌"]
    }
    const procyPerson = reactive(person);

    function updatePerson() {
      procyPerson.name = "李四";
      procyPerson.age = procyPerson.age + 1;
      procyPerson.job.salary = procyPerson.job.salary + 1;
      procyPerson.hobby.push("烫头");
      procyPerson.hobby[0] = "学习";
    }

    // 返回一个对象
    return {
      procyPerson,
      updatePerson,
    }
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
